home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1985 June / Ahoy_Magazine_85-06_1985_Double_L.d64 / one voice player (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  5KB  |  199 lines

  1. 1 rem one voice player (fast)
  2. 2 rem plays "mexican hat dance"
  3. 3 rem
  4. 5 print"[147]":poke53280,0:poke53281,6
  5. 7 print:print"            one voice player"
  6. 8 print:print"            mexican hat dance..."
  7. 10 gosub 9000:goto 120
  8. 60 for n=1 to len(md$(ph))
  9. 61 d%=val(mid$(md$(ph),n,1))
  10. 64 poke gr,ug%:rem normal notes; delete pokes for legato
  11. 65 for i=0 to 1:poke fr(i),pi%(asc(mid$(me$(ph),n,1)),i):next
  12. 66 poke gr,g%
  13. 67 for i=0 to du%(val(mid$(md$(ph),n,1))):next
  14. 68 rem poke gr,ug%:rem staccato notes
  15. 69 next:ph=ph+1:if ph>es% then ph=0
  16. 70 poke gr,ug:return
  17. 100 gosub 60
  18. 110 if peek(653)>0 then end
  19. 120 print "phrase "ph
  20. 190 goto 100
  21. 8997 rem
  22. 8998 rem set up sound shape
  23. 8999 rem
  24. 9000 dim mv$(23),md$(23),me$(23),fr(1)
  25. 9001 dim du%(9),pi%(168,1)
  26. 9007 rem
  27. 9008 rem attack
  28. 9009 rem number from 0 to 15; lower number=sharper attack
  29. 9010 ak%=0
  30. 9015 ak%=ak%*16
  31. 9017 rem
  32. 9018 rem decay
  33. 9019 rem number from 0 to 15; lower number=faster decline
  34. 9020 dy%=5
  35. 9027 rem
  36. 9028 rem sustain
  37. 9029 rem number from 0 to 15; lower number=softer volume during sustain
  38. 9030 sn%=1
  39. 9035 sn%=sn%*16
  40. 9037 rem
  41. 9038 rem release
  42. 9039 rem number from 0 to 15; lower number=faster drop to silence at end
  43. 9040 re%=0
  44. 9047 rem
  45. 9048 rem set sound addresses
  46. 9049 rem
  47. 9050 fr(0)=54272
  48. 9055 fr(1)=1+fr(0):gr=fr(0)+4:ad=gr+1
  49. 9057 rem
  50. 9058 rem poke adsr envelope
  51. 9059 rem
  52. 9060 poke ad,at% or dy%
  53. 9065 poke ad+1,sn% or re%
  54. 9066 rem
  55. 9067 rem set up gate
  56. 9068 rem waveforms (add values):
  57. 9069 rem triangle on=16; sawtooth on=32; pulse on=64 (set width!); noise on=128
  58. 9070 wf%=32
  59. 9075 g%=1 or wf%:ug%=g% and 254
  60. 9077 rem
  61. 9078 rem set pulse width
  62. 9079 rem low byte, high byte
  63. 9080 poke gr-2,200:poke gr-1,3
  64. 9096 rem
  65. 9097 rem set up pitch array
  66. 9098 rem each note, in all its octaves
  67. 9099 rem c
  68. 9100 x%=3:gosub 9190
  69. 9101 data 12,1,24,2,48,4,97,8,195,16,135,33,15,67,30,134
  70. 9102 rem d
  71. 9103 x%=4:gosub 9190
  72. 9104 data 45,1,90,2,180,4,104,9,209,18,162,37,69,75,139,150
  73. 9105 rem e (f-flat)
  74. 9106 x%=5:gosub 9190:y%=13:gosub 9195
  75. 9107 data 81,1,163,2,71,5,143,10,31,21,62,42,125,84,250,168
  76. 9108 rem f (e-sharp)
  77. 9109 x%=6:gosub 9190:y%=19:gosub 9195
  78. 9110 data 102,1,204,2,152,5,48,11,96,22,193,44,131,89,6,179
  79. 9111 rem g
  80. 9112 x%=7:gosub 9190
  81. 9113 data 145,1,35,3,71,6,143,12,30,25,60,50,121,100,243,200
  82. 9114 rem a
  83. 9115 x%=1:gosub 9190
  84. 9116 data 195,1,134,3,12,7,24,14,49,28,99,56,199,112,143,225
  85. 9117 rem b
  86. 9118 x%=2:gosub 9190
  87. 9119 data 250,1,244,3,233,7,210,15,165,31,75,63,151,126,46,253
  88. 9120 rem d-flat (c-sharp)
  89. 9121 x%=11:gosub 9190:y%=17:gosub 9195
  90. 9122 data 28,1,56,2,112,4,225,8,195,17,134,35,12,71,24,142
  91. 9123 rem e-flat (d-sharp)
  92. 9124 x%=12:gosub 9190:y%=18:gosub 9195
  93. 9125 data 62,1,125,2,251,4,247,9,239,19,223,39,191,79,126,159
  94. 9126 rem g-flat (f-sharp)
  95. 9127 x%=14:gosub 9190:y%=20:gosub 9195
  96. 9128 data 123,1,246,2,237,5,218,11,181,23,107,47,214,94,172,189
  97. 9129 rem a-flat (g-sharp)
  98. 9130 x%=8:gosub 9190:y%=21:gosub 9195
  99. 9131 data 169,1,83,3,167,6,78,13,156,26,57,53,115,106,230,212
  100. 9132 rem b-flat (a-sharp)
  101. 9133 x%=9:gosub 9190:y%=15:gosub 9195
  102. 9134 data 221,1,187,3,119,7,239,14,223,29,190,59,124,119,248,238
  103. 9135 rem c-flat
  104. 9136 x%=10:gosub 9190
  105. 9137 data 4,1,250,1,244,3,233,7,210,15,165,31,75,63,151,126
  106. 9138 rem b-sharp
  107. 9139 x%=16:gosub 9190
  108. 9140 data 24,2,48,4,97,8,195,16,135,33,15,67,30,134,255,255
  109. 9150 for i=0 to 147 step 21:pi%(i,0)=0:pi%(i,1)=0:next
  110. 9185 goto 9200
  111. 9189 rem read pitches
  112. 9190 for i=0 to 147 step 21:read pi%(i+x%,0),pi%(i+x%,1):next:return
  113. 9194 rem identical pitches
  114. 9195 for i=0 to 147 step 21:pi%(i+y%,0)=pi%(i+x%,0):pi%(i+y%,1)=pi%(i+x%,1)
  115. 9196 next:return
  116. 9197 rem
  117. 9198 rem set up durations
  118. 9199 rem
  119. 9200 for i=0 to 9:read du%(i):next
  120. 9205 data 16,32,48,64,96,128,160,192,256,320
  121. 9296 rem
  122. 9297 rem set filter and volume
  123. 9298 rem filter frequency
  124. 9299 rem low byte (0-7) x%; high byte (0-255) y%
  125. 9300 x%=0:y%=100
  126. 9305 poke 54293,x%:poke 54294,y%
  127. 9308 rem filter on?
  128. 9309 rem voice 1 on=1
  129. 9310 x%=0
  130. 9318 rem filter resonance
  131. 9319 rem peak volume (0=low, 15=high)
  132. 9320 y%=14
  133. 9325 y%=y%*16:poke 54295,x% or y%
  134. 9328 rem select filter type
  135. 9329 rem low-pass=1;band-pass=2;high-pass=4;lo-band=3;hi-band=6;all=7
  136. 9330 x%=1
  137. 9335 x%=x%*16
  138. 9337 rem
  139. 9338 rem select overall volume
  140. 9339 rem 15=high, 0=low
  141. 9340 y%=15
  142. 9345 poke 54296,x% or y%
  143. 9496 rem
  144. 9497 rem set melody
  145. 9498 rem
  146. 9509 rem how many phrases? (minus one)
  147. 9510 es%=5
  148. 9514 rem
  149. 9515 rem melody strings
  150. 9516 rem
  151. 9517 rem each phrase has only one du%(ph%) string, no matter how many voices
  152. 9518 rem each phrase has one me$(ph%,vc%) & one mv$(ph%,vc%) string per voice
  153. 9519 rem phrase 0
  154. 9520 md$(0)="00000000040000000004"
  155. 9521 me$(0)="g[198]ge[196]ecbcgefgabcdefd"
  156. 9522 mv$(0)="6      565     6    "
  157. 9529 rem phrase 1
  158. 9530 md$(1)="0000000004000000006"
  159. 9531 me$(1)="fefd[195]db[193]bgg[198]gagfedc"
  160. 9532 mv$(1)="6     5   6        "
  161. 9539 rem phrase 2
  162. 9540 md$(2)="000000015000000015"
  163. 9541 me$(2)="gc@gc@gc@gcdcb@cd@"
  164. 9542 mv$(2)="34 34 34 34  3 4  "
  165. 9549 rem phrase 3
  166. 9550 md$(3)="000000015000000015"
  167. 9551 me$(3)="gb@gb@gb@gbcba@bc@"
  168. 9552 mv$(3)="3          43   4 "
  169. 9559 rem phrase 4
  170. 9560 md$(4)="11111111151111111115"
  171. 9561 me$(4)="dddaaacccbdddaaacccb"
  172. 9562 mv$(4)="5  4  5  45  4  5  4"
  173. 9569 rem phrase 5
  174. 9570 md$(5)="1111111115111111118"
  175. 9571 me$(5)="dddaaacccbd[195]dedcbag"
  176. 9572 mv$(5)="5  4  5  45     4  "
  177. 9898 rem convert strings to usable form
  178. 9899 rem
  179. 9900 for ph=0 to es%
  180. 9905 a$=me$(ph):me$(ph)=""
  181. 9910 for i=1 to len(a$)
  182. 9920 x%=asc(mid$(a$,i,1))
  183. 9930 if x%<72 then x%=x%-64:if x%<0 then x%=0
  184. 9931 if x%>192and x%<200 then x%=x%-178
  185. 9932 if x%=176 then x%=8
  186. 9933 if x%=191 then x%=9
  187. 9934 if x%=188 then x%=10
  188. 9935 if x%=172 then x%=11
  189. 9936 if x%=177 then x%=12
  190. 9937 if x%=187 then x%=13
  191. 9938 if x%=165 then x%=14
  192. 9939 if x%>21 then x%=0
  193. 9940 v$=mid$(mv$(ph),i,1):if v$<>" " then y%=21*val(v$)
  194. 9950 x%=x%+y%
  195. 9970 me$(ph)=me$(ph)+chr$(x%)
  196. 9975 next:next
  197. 9980 ph=0
  198. 9990 return
  199.